#define _CRT_SECURE_NO_WARNINGS 1
/**
*      author: Y_Yao
*      created: 2024-09-18 13:32:39
**/

#include<bits/stdc++.h>

using namespace std;
const int N = 2e5 + 7;

void solve()
{
    int n = 0;
    cin >> n;
    string a(N, ' ');
    int zeros = 0;
    int ones = 0;
    for (int i = 0;i < n;i++)
    {
        cin >> a[i];
        if (a[i] == '0') zeros++;
        if (a[i] == '1') ones++;
    }


    if (zeros == 0 && n == 4)
    {
        cout << "YES" << endl;
        return;
    }
    else if (zeros == 0)
    {
        cout << "NO" << endl;
        return;
    }

    int tmp = sqrt(zeros);

    if ((tmp + 2) * (tmp + 2) - zeros != ones)
    {
        cout << "NO" << endl;
        return;
    }

    cout << "YES" << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}